$(function () {
    $("#jqGrid").jqGrid({
        url: baseURL + 'bdbusiness/azhishikuhangye/list',
        datatype: "json",
        colModel: [			
			{ label: 'id', name: 'id', index: 'id', width: 50, key: true ,hidden: true},
			{ label: '标题', name: 'title', index: 'title', width: 80 }, 			
			{ label: '时间', name: 'time', index: 'time', width: 80 }, 			
//			{ label: '内容', name: 'content', index: 'content', width: 80 }, 			
//			{ label: '商机推荐/行业发展趋势预测/获取国内市场动态/获取国际市场动态', name: 'type', index: 'type', width: 80 }, 			
//			{ label: 'URL', name: 'url', index: 'url', width: 80 }			
        ],
		viewrecords: true,
        height: 385,
        rowNum: 10,
		rowList : [10,30,50],
        rownumbers: true, 
        rownumWidth: 25, 
        autowidth:true,
        multiselect: true,
        pager: "#jqGridPager",
        jsonReader : {
            root: "page.list",
            page: "page.currPage",
            total: "page.totalPage",
            records: "page.totalCount"
        },
        prmNames : {
            page:"page", 
            rows:"limit", 
            order: "order"
        },
        gridComplete:function(){
        	//隐藏grid底部滚动条
        	$("#jqGrid").closest(".ui-jqgrid-bdiv").css({ "overflow-x" : "hidden" }); 
        }
    });
});

var vm = new Vue({
	el:'#rrapp',
	data:{
		showList: true,
		title: null,
        q: {
        	title: '',
        },
		aZhishikuHangye: {}
	},
	methods: {
		query: function () {
            $("#jqGrid").setGridParam({'page': 1});
			vm.reload();
		},
		details: function (event) {
			var id = getSelectedRow();
			if(id == null){
				return ;
			}
			vm.showList = false;
            vm.title = "详情";
            vm.getInfo(id)
		},
		getInfo: function(id){
			$.get(baseURL + "bdbusiness/azhishikuhangye/info/"+id, function(r){
                vm.aZhishikuHangye = r.aZhishikuHangye;
            });
		},
		reload: function (event) {
			vm.showList = true;
			var page = $("#jqGrid").jqGrid('getGridParam','page');
			$("#jqGrid").jqGrid('setGridParam',{ 
                postData: vm.q,
                page:page
            }).trigger("reloadGrid");
		}
	}
});